package com.example.demo.mapper;


import com.example.demo.model.BlogInfo;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface BlogInfoMapper {
    /**
     * 查看所有博客
     */
    @Select("select id ,title,content,user_id ,update_time from `blog` where delete_flag = 0 order by id desc")
    List<BlogInfo> selectAll();


    /**
     * 根据博客id ,查看博客
     */
    @Select("select id,title,content,user_id from `blog` where delete_flag = 0 and id = #{id}")


    BlogInfo selectBlog(Integer id);

    /**
     * 新增博客
     */
    @Insert("insert into blog (title,content,user_id) values (#{title},#{content}, #{userId})")

    Integer insertBlog(BlogInfo blogInfo);

    /**
     * 更新博客
     */

//    @Update("update blog set ")
    Integer updateBlog(BlogInfo blogInfo);

}
